package HHD.Sgg.UserADS

import org.apache.spark.sql.SparkSession

object HHDdatas {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().getOrCreate()
    spark.sql(
      """
        |INSERT INTO TABLE HHDtest.fact_page_residence_time (`id`,`user_id`, `page_id`, `go_in_time`, `out_time`)
        |VALUES
        |    ('1','1', '1', CAST('2024-04-25 08:00:00' AS TIMESTAMP), CAST('2024-04-25 08:15:00' AS TIMESTAMP)),
        |    ('2','1', '2', CAST('2024-04-25 08:05:00' AS TIMESTAMP), CAST('2024-04-25 08:20:00' AS TIMESTAMP)),
        |    ('3','2', '3', CAST('2024-04-25 08:10:00' AS TIMESTAMP), CAST('2024-04-25 08:25:00' AS TIMESTAMP)),
        |    ('4','1', '1', CAST('2024-04-24 08:00:00' AS TIMESTAMP), CAST('2024-04-24 08:16:00' AS TIMESTAMP)),
        |    ('5','1', '2', CAST('2024-04-24 08:05:00' AS TIMESTAMP), CAST('2024-04-24 08:21:00' AS TIMESTAMP)),
        |    ('6','1', '3', CAST('2024-04-24 08:10:00' AS TIMESTAMP), CAST('2024-04-24 08:26:00' AS TIMESTAMP)),
        |    ('7','2', '1', CAST('2024-04-18 08:00:00' AS TIMESTAMP), CAST('2024-04-18 08:17:00' AS TIMESTAMP)),
        |    ('8','2', '2', CAST('2024-04-18 08:05:00' AS TIMESTAMP), CAST('2024-04-18 08:22:00' AS TIMESTAMP)),
        |    ('9','2', '3', CAST('2024-04-18 08:10:00' AS TIMESTAMP), CAST('2024-04-18 08:27:00' AS TIMESTAMP)),
        |    ('10','3','1', CAST('2024-04-11 08:00:00' AS TIMESTAMP), CAST('2024-04-11 08:18:00' AS TIMESTAMP));
        |""".stripMargin)

    spark.sql(
      """
        |INSERT INTO TABLE HHDtest.fact_user_login (`id`, `user_id`, `login_time`, `logout_time`)
        |VALUES
        |    ('1', '1', CAST('2024-04-25 08:00:00' AS TIMESTAMP), CAST('2024-04-25 08:30:00' AS TIMESTAMP)),
        |    ('2', '2', CAST('2024-04-25 08:05:00' AS TIMESTAMP), CAST('2024-04-25 08:35:00' AS TIMESTAMP)),
        |    ('3', '3', CAST('2024-04-25 08:10:00' AS TIMESTAMP), CAST('2024-04-25 08:40:00' AS TIMESTAMP)),
        |    ('4', '1', CAST('2024-04-24 08:00:00' AS TIMESTAMP), CAST('2024-04-24 08:31:00' AS TIMESTAMP)),
        |    ('5', '2', CAST('2024-04-24 08:05:00' AS TIMESTAMP), CAST('2024-04-24 08:36:00' AS TIMESTAMP)),
        |    ('6', '3', CAST('2024-04-24 08:10:00' AS TIMESTAMP), CAST('2024-04-24 08:41:00' AS TIMESTAMP)),
        |    ('7', '1', CAST('2024-04-18 08:00:00' AS TIMESTAMP), CAST('2024-04-18 08:32:00' AS TIMESTAMP)),
        |    ('8', '2', CAST('2024-04-18 08:05:00' AS TIMESTAMP), CAST('2024-04-18 08:37:00' AS TIMESTAMP)),
        |    ('9', '3', CAST('2024-04-18 08:10:00' AS TIMESTAMP), CAST('2024-04-18 08:42:00' AS TIMESTAMP)),
        |    ('10', '1',CAST( '2024-04-11 08:00:00' AS TIMESTAMP),CAST( '2024-04-11 08:33:00' AS TIMESTAMP));
        |""".stripMargin)

    spark.sql(
      """
        |INSERT INTO TABLE HHDtest.dim_page_info (`id`, `page`, `create_time`)
        |VALUES
        |    ('1', 'index', CAST('2024-04-25 08:00:00' AS TIMESTAMP)),
        |    ('2', 'by_index', CAST('2024-04-25 08:05:00' AS TIMESTAMP)),
        |    ('3', 'sku_index', CAST('2024-04-25 08:10:00' AS TIMESTAMP));
        |""".stripMargin)

    spark.sql(
      """
        |INSERT INTO TABLE HHDtest.dim_user_info (id,name,create_time)
        |VALUES
        |    ('1','张三',CAST("2024-04-25 06:00:00" AS TIMESTAMP)),
        |    ('2','李四',CAST("2024-04-24 07:03:00" AS TIMESTAMP)),
        |    ('3','赵大',CAST("2024-04-22 17:23:01" AS TIMESTAMP));
        |""".stripMargin)

  }
}
